﻿using CanDoo.Admin.Core.Contracts;
using CanDoo.Admin.Core.Models;
using CanDoo.Core.Data;
using Microsoft.AspNet.Identity;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CanDoo.Admin.Core.Contracts.Base
{

    public class RoleStore : IRoleStore<Role, long>,CanDoo.Core.Dependency.IScopeDependency
    {
        public IRoleContract RoleContract { get; private set; }
        public RoleStore(IRoleContract roleContract)
        {
            RoleContract = roleContract;
        }
        public Task CreateAsync(Role role)
        {
            return Task.FromResult(RoleContract.AddEntity(role));
        }

        public Task DeleteAsync(Role role)
        {
            return Task.FromResult(RoleContract.DeleteEntity(role));
        }

        public void Dispose()
        {
            return;
        }

        public Task<Role> FindByIdAsync(long roleId)
        {
            return Task.FromResult(RoleContract.GetById(roleId));
        }

        public Task<Role> FindByNameAsync(string roleName)
        {
            return RoleContract.FindByNameAsync(roleName);
        }

        public Task UpdateAsync(Role role)
        {
            return RoleContract.UpdateAsync(role);
        }
    }
}
